Square root apparatus



United States Patent OTHER REFERENCES [72] Inventor Gerald W. Price Huntsfinfi Lenaerts, EIH. Automatic Square Rooting. In electronic en- I U PP 601,812 gineering. 27 (329): pp. 287- 289..Iuly 1955.TK6630A2T2. [22] Filed Dec. 14, 1966 [45] Patented Dec'291970 PrimaryExaminer-Eugene G. Bot z 731 Assignee the United States of America as represented j f gf g' q if ggl g 2:1 :22; f Herbert by the Secretary of the Army Bed and Aubrey J. Dunn [54] g igg g ggf ABSTRACT: The apparatus includes a number register in i which the number whose square root is desired is entered. In U.S. response t ig l f a t l ti a constants g [51] Int. Cl G06f 7/38, tor provides Successive integers The successive Odd integers 1/04 are subtracted, in an adder-subtractor, from the number, until ofSearch a hange of i n of the remainder is detected sign-of.

number detector. The number of subtractions necessary be- [561 References C'ted fore the change of sign of the remainder is accumulated in an UNITED STATES PATENTS answer register. An inhibit circuit is included to exclude even 2,75l,l49 6/1956 Young et a]. 235/ I58 integers from the adder-subtractor. The adder-subtractor, 2,888,200 5/1959 Weiss 235/158 sign-of-number detector, inhibit circuit, number register, and 3,280,3 l4 10/1966 Weigler 235/158 answer register are all controlled by the control section.

SIGN OF ANSWER NUMBER REGISTER NUMBER ADDER- REGISTER SUBTRACTOR CONSTANTS EVEN WORD GENERATOR lNHlBlT CONTROL SECTION PATENTEUuaczemm $551,652

SHEET 1 0F 2 SIGN OF ANswER NUMBER REGISTER I E I NUMBER ADDER- REGISTER SUBTRACTOR CONSTANTS 36% GENERATOR INHIBIT CONTROL SECTION FIG. I

Gerald W. Price,

INVENTOR.

SQUARE ROOT APPARATus This invention relates to a method and apparatus for computing the square roots of binary numbers.

Heretofore. the computation of square roots with a general purpose computer has been a long and complicated process. One way in which this might be accomplished is by storing (in binary form) a number whose square root is desired, in a storage position of the computer. and storing, in another position, a binary'number The number x" is squared and the resulting product is subtracted from b." if the difference (b-x) is positive, a binary 1" is added to the most significant position of and x" is again squared and subtracted from b." When the sign of the difi'erence between b" and x becomes negative. the square root of b" obviously must lie between the present value of x" and (.r-l The next least significant binary position of x" would be treated in like manner. If the original difference between b" and x had been negative. a binary 1" would have been subtracted from 'x." and "it" would be again squared, etc.

It can be seen from the above that four subtractions of successive odd integers were necessary to reach a difference of zero. Therefore. by this method, the square root of 16 is found to be 4.

For numbers which are not exact squares, the process becomes more difficult.

Using the above process. the square root of 3 would'be found as follows:

Only one odd number can be subtracted from 3 without the difference being less than the next succeeding odd n mber (3). It can be seen that the square root of 3, to one decimal accuracy. 300 could be used instead of 3. The square root process would proceed as follows:

EOMNQUTIFOON lt can be seen that 17 subtractions of successive odd integers are necessary before the difference is less than the next successive odd integer (35); or, the square root is 17. In order to take the square root to another decimal place, 30,000 could be used, and 173 subtractions would be necessary before a difference less than the next successive odd number. This process rapidly gets out of hand if six or seven place accuracy is required.

The number of steps to find a square root can be reduced if the following process is used. When the remainder aftera sub-,

traction is less than the next odd number, the remainder ismultiplied by the partial root is doubled and multiplied 'by l0 and l is added to the product. The resulting number is taken as the first number in a new series of odd numbers. A specific example, such as the square root of 3, is of help in unplace. is l. with a remainder. [f it is d es ir ed to g et greater 55 :lerstanding this method.

Thus 3 Multiply remainder by 1 00 (Partial root doubled, multiplied by 10 and with 1 added) 1 (Partial root).

(Square root is now 17 or 1.7).

(Square root now reads 173 or 1.73).

3, 463 2 (Square root new reads 1732 or 1.732).

9 Sub 00 I square root is now 17,320 or 1.7320.

17,600 is again multiplied by 100 to give 1,760,000, and 17,320 is doubled and multiplied by 10 and l is added to give 346.401.

Then:

Thus the square root of 3 is 1.73205. It is obvious that this process requires very few subtractions, compared to the previous process described.

This last process or method may be applied to the extraction ofa square root ofa binary number. Certain modifications are necessary in modulo 2 systems as the highest order of the odd series of numbers is the odd Only one subtraction for each binary square root grouping would be required. If this subtraction is accomplished without changing the sign of the minuend, then a binary one is indicated for that groupings contribution to the final square root answer. This general procedure is repeated for each subsequent square root grouping, except there are particular changes that must be generated for later decades. For the second subtrahend, the answer obtained thus far is doubled and placed beside the odd series bit position in most significant position. As this odd series bit is always a 1," the new subtrahend is the answer doubled and placed along with the integer 1" in the less significant position. Each succeeding subtrahend is generated by doubling the previous answer and placing this with the new odd bit with the doubled answer in the more significant position. After subtraction, if the sign of the minuend has changed, the minuend must be restored by adding the subtrahend back to the minuend. These procedures can be noted in detail in the following example. In this example, the square root of 990,025 is extracted.

(1) Sub 01 O0 00 0O 00 00 00 00 00 -00 (2) circulate 00 00 00 00 00 O0 00 00 0O 0O 10 11 00 01 10 11 01 00 10 01 (3) Sub 01 01 00 00 00 00 0O ()0 00 00 01 10 00 01 10 ll 01 00 10 01 (4) circulate 0O 0O 00 00 00 00 00 00 0O 00 01 10 00 01 10 11 O1 O0 10 01 (5) Sub 00 11 01 00 00 00 00 00 00 00 (6) circulate 00 00 O0 00 00 0O 00 00 00 00 00 1O 1 01 10 11 01 00 10 01 (7) Sub 0O 01 11 01 00 00 00 00 00 0O (8) circulate 00 00 00 00 0O 0O 00 00 00 00 0O 01 00 10 11 01 00 10 01 (10) Circulate O0 00 00 (11) Sub 00 00 01 11 11 10 01 1O 10 01 00 10 01 (12) Add 00 00 01 11 11 01 00 O0 00 00 00 00 O0 01 01 11 01 00 10 01 (13) Sub 00 00 00 11 11 1O 01 00 0O 00 11 11 11 01 0 01 00 00 10 01 (14) Add 00 00 0O 11 11 10 01 00 00 00 00 0O 00 01 01 11 01 0O 10 01 (15) Sub 0O 00 00 01 1 11 00 01 00 O0 11 11 11 11 10 00 00 11 10 01 (16) Add 00 00 00 01 11 11 00 01 00 00 17) Sub 00 00 00 00 11 11 10 00 01 00 00 00 00 00 01 11 11 00 01 01 (1s Circulate 00 00 00 00 00 00 00 00 00 00 (19) Sub 00 00 00 00 01 11 11 00 01 01 00 0o 00 0o 00 00 0000 00 00 (20)C1rcu1ate 00 00,00 00 00 00 00 00 00; 00

EXAMPLE" The binary number is set off in groups of two,'as is required by any square root operation, from the least significant digit. The subtrahend, 01 00 00 00 0000 00 00 00, which is equivalent to subtracting thebinary l 'f from th e most significant group of the minuend, is subtracted. The remainder, 10 11' 00 01 10 11 01 00 10 01, is still ofthe same sign as the subtrahend was not larger than'the minuend, and therefore, a l digit is placed in the answer position for the most significant group. As the sign did not change, the restoring step is not required and a circulation without change is indicated. The next subtrahend is determined by doubling the previous answer, shifting down one bit, and placing this beside the odd series 1, i.e.,

1 answer register,

and the new subtrahend is 01 01 00 0000 Q0 00 00 00 00. The procedure is continued through stepQ'Nb. 1 1, where the'fsign changes and the restoring addition 'o'f the subtrahend is performed. As the result of the appearance of the negative number, the answer for that grouping is0, i.e., l 1 l 1 l 0 The sign continues to be negativethrough step No. 13 and No. 15 for additional zeros. The sign remains positive for steps No.17 and No. l9forafinalanswerof1111100 0 1 1. This is the number 995 and is the correct answer to the square root of 990,025.

An apparatus for performing the method must have, at least, some means for generating a series of successive odd integers, an arithmetic unit in which to perform the various arithmetic operations, and registers in which to store the various numbers.

BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1 shows a schematic diagram of the invention, FIG. 2 shows details of element 7 of FIG. 1, and FIG. 3 shows details of element 2 of FIG. 1.

Referring now to FIG. 1, the inventive apparatus is seen to consist of a number register 1, into which is entered the number whose square root is desired. A constants generator 2 generates the subtrahend and retains it for the possibility of restoring the minuend if the remainder is negative. An addersubtractor 3 performs the addition and subtraction operations. An element 4 senses the sign of the number and governs whether an addition or subtraction is performed. The answer register 5 stores the answer. The even-word inhibit element 6 insures that only odd numbers (words) are used in adder-subtractor element 3. The overall operation of the circuit is controlled and coordinated by a control section 7. This control section can take anyone of several forms. The requirement is for a circuit capable of providing a repetitive decimal count on respective output lines. One example of such a circuit might include a clock feeding a binary counter, with a binary-todecimal converter connected to the counter. Such a circuit is shown in the Instruction Manual for 200-KC S-PAC Digital Modules of Aug. 5, 1963, by Computer Control Company, Inc., of Massachusetts, Mass, on page 3 l 74, in FIG. 3-266. This circuit provides a decimal count only to 15. but could obviously be extended to any desired number. The general arrangement of this circuit is shown in FIG. 2, wherein 21 designates the clock, 22 designates the binary counter, and 23 designates the binary-to-decimal converter. As can be seen, converter 23 has outputs 24.

l l l l The constants generator consists of two shift registers A and B with tap selectors for each. The binary number 0100000000000000000000 is set in shift register A and this number is never changed or removed, but is circulated in the register during each word. The constants generator can generate this number (010000000000000000000) on the first and second word of each solution by tap selector 31 taking the number from the last bit of this register. The 01 in the first two bits of this number moves over to the right two bits on each odd word (s'ee solution No. 2 of table I and the previous problem exariliil'e)-.- T liis is accomplished in shift register A by moving the tab selector dver two bits on each odd word.

The other part of the constant is generated in second shift register B. There is nothing set in this register at the beginning of a solution. At the end of each word, a I or is set in the next bit, starting with bit number 2, depending on whether the number in the number register is positive or negative, respectfully. This is accomplished in bit set portion 33 of the constants generator. On each odd word after the bits are set in the second shift register, they must be shifted one bit to the right before the next subtraction (see table 1). This is accomplished by moving tap selector 32 over to the left one bit on each odd word starting with word number 3.

The output of first shift register A and of second shift register B is combined at the output of the constants generator by OR gate 34 and when the output of either register is a l, the output of the constants generator is a I.

provided to inhibit the word from going into the adder-subtractor (see even word inhibit block in FIG. 1) when the remainder does not go negative on the first word.

For the third word, the constants generator must generate 00010000000000000000 or 01010000000000000000 to be subtracted from the number and depends on whether the number was negative or positive. respectfully, at the end of the first word.

From the discussion and table I, it can be seen that the constants generator always generates the same number on the first and second words of any solution, and that it generates a new number on every odd word and holds this number through the next even word. This new number that is generated on every odd word, is determined by the sign of the previous odd number.

Each of the blocks of the drawing is known in the art, and the invention is to be the novel combination of these blocks. This inventive combination may be built as a special-purpose computer, of a general-purpose computer may be programmed to operate like the inventive combination.

While the method has been described as applicable to binary and decimal number systems, the technique is usable with any modulo, as long as the number is expressed as a positional number. The square roots of fractional numbers can be determined by converting the fraction to a corresponding positional number or by finding the square root of the numerator and denominator separately,

TABLE 1 Solution No. 1 Solution No. 2 Solution No. 3

ign Constants Sign Constants Sign Constants Word No. of N o. Generator of N o. Generator of N o. Generator Table I IS a table of constants that must be generated for the l Clalml word number indicated. The number that must be generated is detennined by the sign of the number in the number register.

Solution No. I shows the numbers the constants generator would have to generate 1f the subtraction never caused the remainder to go negative. In solution No. 2, the subtraction always causes the remainder to go negative and solution No. 3 is an example that combines positive and negative numbers.

It can be observed from table 1 that on the first word of every solution, the constants generator must generate 0100000000000000000 to be subtracted from the number in the number register. If this subtraction causes the remainder to go negative, then on the second word the constants generator must generate 01000000000000000000 to be added back to the number. If the number does not go negative on the first word, a simple circulation is performed. Therefore, the constants generator can always generate a 01000000000000000000 on the second word and a block be l. A computer for computing square roots of numbers, including; an input register for said numbers, having an input and outputs; a constants generator having an input and an output; arithmetic means having inputs and an output; means to inhibit even constants having inputs and an output, with a first of its inputs connected to the output of said constants generator and its output connected to a first input of said arithmetic means; a first output of said input register connected to a second input of said arithmetic means; an answer register; a sign of number detector having an input connected to a second output of said input register, and having an output connected to said answer register, to said input of said constants generator, and to a second input of said means to inhibit; said output of said arithmetic means connected to said input of said input register; and control means connected to each input register, constants generator, arithmetic means, means to inhibit, answer register, and sign-of-number detector. 

